{% extends "messages/base.html" %}
{% from "messages/includes/macros.html" import avatar_link, name_link %}
{% set title = _('Inbox') %}
{% set crumbs = [(None, title)] %}
{% set active_tab = 'inbox' %}

{% block content %}
  <div class="grid_9">
    <section class="actions">
      <a href="{{ url('messages.new') }}">{{ _('New Message') }}</a>
    </section>
    <article id="inbox" class="main">
      <h1>{{ title }}</h1>
      {% if msgs %}
        <form action="{{ url('messages.bulk_action') }}" method="POST">
          <input type="submit" name="mark_read" value="{{ _('Mark Selected as Read') }}">
          <input type="submit" name="delete" value="{{ _('Delete Selected') }}">
          <ol class="message-list">
            {% for message in msgs.object_list %}
              <li class="{% if message.unread %}unread{% endif %}
              {% if message.replied %}replied{% endif %} cf">
                <input type="checkbox" name="id" value="{{ message.id }}">
                <span class="avatar">
                  {{ avatar_link(message.sender) }}
                </span>
                <span class="from user">
                  {{ name_link(message.sender) }}
                  {{ datetimeformat(message.created) }}
                </span>
                <a class="read" href="{{ url('messages.read', message.id) }}" title="{{ _('Read message') }}">
                  {{ message.content_parsed|striptags|truncate(length=160) }}
                </a>
                <a class="delete" href="{{ url('messages.delete', message.id) }}" title="{{ _('Delete message') }}">&#x2716;</a>
              </li>
            {% endfor %}
          </ol>
          {% csrf_token %}
        </form>
        {{ msgs|paginator }}
      {% else %}
        <p>{{ _('There are no messages here.') }}</p>
      {% endif %}
    </article>
  </div>
{% endblock %}
